<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layout/layout}">
<head>
    <meta charset="UTF-8">
    <title>home</title>
</head>
<body>
<div layout:fragment="content">
    <i-form :modal="form" :label-width="150">
        <Form-item label="角色名：">
            <i-input v-model="form.roleName" placeholder="请输入角色名"></i-input>
        </Form-item>
        <Form-item label="备注：">
            <i-input v-model="form.mark" placeholder="请输入备注"></i-input>
        </Form-item>
        <i-button type="success" size="large" @click="save">保存</i-button>
        <i-button type="ghost" size="large" @click="location.href='/admin/role'">取消</i-button>
    </i-form>
</div>
<script layout:fragment="script" th:inline="javascript">
    var mixin = {
        data: function () {
            return {
                menuActive: '0',
                form: {
                    roleName: "",
                    mark: ""
                }
            }
        },
        methods: {
            save: function () {
                var _this = this;
                axios({
                    method: 'post',
                    url: '/admin/role/save',
                    data: Qs.stringify(_this.form),
                }).then(function (res) {
                    var data = res.data;
                    _this.$nextTick().then(function () {
                        _this.data = data;
                    });
                    if (data == '') {
                        _this.$Message.warning("暂无数据！");
                    } else {
                        _this.$Message.success("保存完成！");
                        window.location.href = '/admin/role'
                    }
                }).catch(function (res) {
                    //异常错误
                })
            }
        }
    }
</script>
</body>
</html>